#pragma once

#include <QDialog>
#include <ui_MaterialSetting.h>
#include "Material.h"
#include "Objects.h"
#include <qmessagebox.h>
#include <qmenu.h>
#include <qlineedit.h>
#include <qinputdialog.h>
#include <qcolordialog.h>
#include "CheckboxSetting.h"

class MaterialSetting : public QDialog
{
	Q_OBJECT

public:
	MaterialSetting(obj* obj, QWidget *parent);
private slots:

	void onMatListMenuRequested(const QPoint&);
	void onTexListMenuRequested(const QPoint&);

	void onCreateDiffuse();
	void onCreateMirror();
	void onCreateMetal();
	void onCreateFlat();
	void onCreateEmission();
	void onDeleteMat();
	void onRenameMat();
	void onSelectMat();
	void onRoughnessChanging(int value);
	void onRoughnessChanged();

	void onCreatePureColor();
	void onCreateCheckbox();
	void onSelectTex();
	void onEditTex(QListWidgetItem* item);
	void onDeleteTex();
	void onRenameTex();

	void onApply();

private:
	Ui::MaterialDialog ui;
	World preview;
	QPixmap view;
	QMap<QListWidgetItem*, material*> matMap;
	QMap<QListWidgetItem*, texture*> texMap;
	obj* object;
	material* selectedMat = NULL;
	texture* selectedTex = NULL;

	QMenu* materialMenu;
	QMenu* addMatMenu;
	QAction* addDiffuse;
	QAction* addMirror;
	QAction* addMetal;
	QAction* addFlat;
	QAction* addEmission;
	QAction* deleteMat;
	QAction* renameMat;

	QMenu* texMenu;
	QMenu* addTexMenu;
	QAction* addPureColor;
	QAction* addCheckbox;
	QAction* deleteTex;
	QAction* renameTex;

	void updateMatList();
	void updateTexList();
};
